﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FindPharmacies.Model;

namespace FindPharmacies.Models
{
    public class JsonPharmacy
    {
        public JsonPharmacy() { }
        public JsonPharmacy(Pharmacy pharmacy)
        {
            PharmacyID = pharmacy.PharmacyID;
            Latitude = pharmacy.Latitude;
            Longitude = pharmacy.Longitude;
            Name = pharmacy.Name;
            Street = pharmacy.Street;
            No = pharmacy.No;
            City = pharmacy.City;
            Zip = pharmacy.Zip;
            Phone = pharmacy.Phone;
            Email = pharmacy.Email;
            Website = pharmacy.Website;
            OpeningHours = pharmacy.OpeningHours;
            EmergencyTimes = pharmacy.EmergencyTimes;
            EmergencyService = pharmacy.EmergencyService;
            Url = "pharmacy/details/" + pharmacy.PharmacyID.ToString();

        }

        public int PharmacyID { get; set; }
        public double Latitude { get; set; }
        public double Longitude { get; set; }
        public string Name { get; set; }
        public string Street { get; set; }
        public string Url { get; set; }
        public string City { get; set; }
        public int Zip { get; set; }
        public int No { get; set; }
        public bool EmergencyService { get; set; }
        public string Phone { get; set; }
        public string Email { get; set; }
        public string Website { get; set; }
        public string OpeningHours { get; set; }
        public string EmergencyTimes { get; set; }
    }

    public class PharmacyViewModel
    {

        public static IList<JsonPharmacy> GetJsonPharmacies(IEnumerable<Pharmacy> pharmacies)
        {
            var result = new List<JsonPharmacy>();
            pharmacies.ToList().ForEach(x => result.Add(new JsonPharmacy(x)));
            return result;
        }

        public static IList<JsonPharmacy> GetJsonEmergencyPharmacies(IEnumerable<Pharmacy> pharmacies)
        {
            var result = new List<JsonPharmacy>();
            pharmacies.ToList().ForEach(x => result.Add(new JsonPharmacy(x)));
            return result;
        }

        //public static IList<PharmacyViewModel> GetPharmaciesView(IEnumerable<Pharmacy> pharmacies)
        //{
        //    var result = new List<PharmacyViewModel>();
        //    foreach (var pharmacy in pharmacies)
        //    {
        //        result.Add(new PharmacyViewModel(pharmacy));
        //    }
        //    return result;
        //}


        //public PharmacyViewModel(Pharmacy pharmacy)
        //{
        //    pharmacy = new Pharmacy();

        //}
    }
}